/**
 * 智慧社区管理系统 - 移动端投诉建议API接口
 * @author Wu.Liang
 * @date 2025-01-21
 * @description 移动端工程位于smart-community-app文件夹，严格遵循架构总览中的项目结构规范
 */

import request from './request'

// 投诉管理API
export const complaintApi = {
  // 分页查询投诉列表
  getComplaintList: (params) => {
    return request.get('/api/complaints', { params })
  },

  // 获取投诉详情
  getComplaintDetail: (complaintId) => {
    return request.get(`/api/complaints/${complaintId}`)
  },

  // 创建投诉
  createComplaint: (data) => {
    return request.post('/api/complaints', data)
  },

  // 更新投诉
  updateComplaint: (complaintId, data) => {
    return request.put(`/api/complaints/${complaintId}`, data)
  },

  // 删除投诉
  deleteComplaint: (complaintId) => {
    return request.delete(`/api/complaints/${complaintId}`)
  },

  // 获取投诉统计
  getComplaintStatistics: (params) => {
    return request.get('/api/complaints/statistics', { params })
  },

  // 上传投诉图片
  uploadComplaintImage: (file) => {
    return request.upload('/api/complaints/upload', file)
  }
}

// 投诉类型管理API
export const complaintTypeApi = {
  // 获取投诉类型列表
  getComplaintTypeList: (params) => {
    return request.get('/api/complaint-types', { params })
  },

  // 获取投诉类型详情
  getComplaintTypeDetail: (typeId) => {
    return request.get(`/api/complaint-types/${typeId}`)
  },

  // 创建投诉类型
  createComplaintType: (data) => {
    return request.post('/api/complaint-types', data)
  },

  // 更新投诉类型
  updateComplaintType: (typeId, data) => {
    return request.put(`/api/complaint-types/${typeId}`, data)
  },

  // 删除投诉类型
  deleteComplaintType: (typeId) => {
    return request.delete(`/api/complaint-types/${typeId}`)
  }
}

// 投诉处理API
export const complaintProcessApi = {
  // 处理投诉
  processComplaint: (complaintId, data) => {
    return request.post(`/api/complaints/${complaintId}/process`, data)
  },

  // 回复投诉
  replyComplaint: (complaintId, data) => {
    return request.post(`/api/complaints/${complaintId}/reply`, data)
  },

  // 关闭投诉
  closeComplaint: (complaintId, data) => {
    return request.post(`/api/complaints/${complaintId}/close`, data)
  },

  // 重新开启投诉
  reopenComplaint: (complaintId) => {
    return request.post(`/api/complaints/${complaintId}/reopen`)
  },

  // 获取投诉处理记录
  getComplaintProcessRecords: (complaintId) => {
    return request.get(`/api/complaints/${complaintId}/process-records`)
  }
}

// 满意度评价API
export const satisfactionApi = {
  // 提交满意度评价
  submitSatisfaction: (complaintId, data) => {
    return request.post(`/api/complaints/${complaintId}/satisfaction`, data)
  },

  // 获取满意度评价
  getSatisfaction: (complaintId) => {
    return request.get(`/api/complaints/${complaintId}/satisfaction`)
  },

  // 获取满意度统计
  getSatisfactionStatistics: (params) => {
    return request.get('/api/satisfaction/statistics', { params })
  }
}

// 常见问题API
export const faqApi = {
  // 分页查询常见问题
  getFAQList: (params) => {
    return request.get('/api/faqs', { params })
  },

  // 获取常见问题详情
  getFAQDetail: (faqId) => {
    return request.get(`/api/faqs/${faqId}`)
  },

  // 创建常见问题
  createFAQ: (data) => {
    return request.post('/api/faqs', data)
  },

  // 更新常见问题
  updateFAQ: (faqId, data) => {
    return request.put(`/api/faqs/${faqId}`, data)
  },

  // 删除常见问题
  deleteFAQ: (faqId) => {
    return request.delete(`/api/faqs/${faqId}`)
  },

  // 搜索常见问题
  searchFAQs: (keyword) => {
    return request.get('/api/faqs/search', { params: { keyword } })
  }
}

// 投诉设置API
export const complaintSettingApi = {
  // 获取投诉设置
  getComplaintSettings: () => {
    return request.get('/api/complaints/settings')
  },

  // 更新投诉设置
  updateComplaintSettings: (data) => {
    return request.put('/api/complaints/settings', data)
  },

  // 获取通知设置
  getNotificationSettings: () => {
    return request.get('/api/complaints/settings/notifications')
  },

  // 更新通知设置
  updateNotificationSettings: (data) => {
    return request.put('/api/complaints/settings/notifications', data)
  },

  // 获取自动回复设置
  getAutoReplySettings: () => {
    return request.get('/api/complaints/settings/auto-reply')
  },

  // 更新自动回复设置
  updateAutoReplySettings: (data) => {
    return request.put('/api/complaints/settings/auto-reply', data)
  }
}

// 投诉分类API
export const complaintCategoryApi = {
  // 获取投诉分类列表
  getCategoryList: (params) => {
    return request.get('/api/complaint-categories', { params })
  },

  // 获取分类下的投诉
  getComplaintsByCategory: (categoryId, params) => {
    return request.get(`/api/complaint-categories/${categoryId}/complaints`, { params })
  },

  // 获取分类统计
  getCategoryStatistics: () => {
    return request.get('/api/complaint-categories/statistics')
  }
}

// 默认导出
export default {
  complaintApi,
  complaintTypeApi,
  complaintProcessApi,
  satisfactionApi,
  faqApi,
  complaintSettingApi,
  complaintCategoryApi
} 